package satir.command;

import satir.SatirGame;
import satir.player.Player;

/**
 * Random reorder players.
 *
 * @version 2.0 March 2012
 * @author Bill Chan
 */

public class SwapPlayersOrderCmd implements Command {
	
	/** The satir game. */
	private SatirGame satirGame;
	
	/**
	 * Instantiates a new swap players order cmd.
	 *
	 * @param satirGame the satir game
	 */
	public SwapPlayersOrderCmd(SatirGame satirGame){
		this.satirGame = satirGame;
	}
	
	/* (non-Javadoc)
	 * @see stair.command.BoardCmd#execute()
	 */
	public void execute() {
		for(int i = 0; i < satirGame.getNumOfPlayer(); i++) { 
			int j = (int) (Math.random() * satirGame.getNumOfPlayer());

			Player temp = satirGame.getPlayers(i);
			satirGame.getArrayListPlayer().set(i, satirGame.getPlayers(j));
			satirGame.getArrayListPlayer().set(j, temp);
			
			/*
			Player temp = playersTemp[i];
			playersTemp[i] = playersTemp[j];
			playersTemp[j] = temp;
			*/
		} 
	}
}
